/*
 * @Description: 
 * @Author: 张文韬
 * @Date: 2022-09-06 14:46:31
 * @LastEditTime: 2024-07-16 14:14:03
 * @LastEditors: 张文韬
 * @Reference: 
 */
import { 
  createInput, 
  createSelect,
  createDateSelect
} from "@/utils/e-components.tool"
import { personCertificateTypes } from '/@/utils/constants'

const columns = [
  {
    label: '投保人姓名',
    minWidth: 120,
    prop: 'name',
  },
  {
    label: '性别',
    minWidth: 80,
    prop: 'sexCode',
    format: (text) => text === 'F' ? '女' : '男'
  },
  {
    label: '证件类型',
    minWidth: 100,
    prop: 'certificateType',
    slotName: 'certificateType'
    // format: (text) => personCertificateTypes.find(item => item.value == text)?.label
  },
  {
    label: '证件号码',
    minWidth: 160,
    prop: 'certificateNo'
  },
  {
    label: '出生日期',
    minWidth: 160,
    prop: 'birthday'
  },
  {
    label: '手机号码',
    minWidth: 160,
    prop: 'mobileTelephone'
  },
  {
    label: '操作',
    fixed: 'right',
    width: 185,
    slotName: 'handleSlot'
  }
]



export const editFormRules = {
  name: [
    { required: true, message: '请输入被保险人姓名', trigger: 'blur' }
  ],
  certificateNo: [
    { required: true, message: '请输入证件号码', trigger: 'blur' },
  ],
  mobileTelephone: [
    // { required: true, message: '请输入手机号码', trigger: 'blur' },
    // { type:'number', message: '手机号码格式错误', }
  ]
};


export const editFormOptions = [
  createInput('投保人', 'name').setSpan(24).option(),
  createSelect('证件类型', 'certificateType')
    .setProps({clearable: false})
    .setOptions(personCertificateTypes)
    .setChanged('cardTypeChange')
    .setSpan(10)
    .option(),
  createInput('证件号码', 'certificateNo')
    .setOnBlur('cardNumberChange')
    .setSpan(14)
    .option(),
  // createInput('年龄', 'age').setProps({disabled: true}).setSpan(12).option(),
  createDateSelect('出生日期', 'birthday')
    .setProps({type: 'date', disabled: true, valueFormat: 'YYYY-MM-DD'})
    .setSpan(12)
    .option(),
  createSelect('性别', 'sexCode')
    .setOptions([{ label: '女', value: 'F' },{ label: '男', value: 'M' }])
    .setProps({disabled: true})
    .setSpan(12)
    .option(),
  createInput('手机号码', 'mobileTelephone').setProps({maxlength: 11}).setSpan(12).option(),
  
  createSelect('与投保人关系', 'relationshipWithApplicant').setSpan(12).option(),
]

export default {
  columns,
  editFormRules,
  editFormOptions
}